package com.anos.smsfun.model;

import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;

import com.anos.smsfun.cache.SMSFunDB.ContactColumns;
import com.anos.smsfun.utility.Utils;

public class ContactsWrapper implements Parcelable {

	private long mContactId;
	private String mDisplayName;
	private String mDisplayNumber;
	
	private boolean mIsUse;// checked,...

	public ContactsWrapper(long contactId, String displayName,
			String displayNumber) {
		this.mContactId = contactId;
		this.mDisplayName = displayName;
		this.mDisplayNumber = Utils.converStandardNumber(displayNumber);
		this.mIsUse = false;
	}

	public ContactsWrapper(Cursor contactCursor, Cursor castCursor) {
		mContactId = contactCursor.getLong(contactCursor
				.getColumnIndex(ContactColumns._ID));
		mDisplayName = contactCursor.getString(contactCursor
				.getColumnIndex(ContactColumns.DISPLAY_NAME));
		mDisplayNumber = contactCursor.getString(contactCursor
				.getColumnIndex(ContactColumns.PHONE_NUMBER));
	}

	public long getContactId() {
		return mContactId;
	}

	public String getDisplayName() {
		return mDisplayName;
	}

	public String getDisplayNumber() {
		return mDisplayNumber;
	}

	// //////////////////////////////////////////////
	// * Bắt đầu phần implements Parceable //////////
	// //////////////////////////////////////////////

	/**
	 * Constructor private, tạo một instance từ parcel
	 */
	private ContactsWrapper(Parcel in) {
		mContactId = in.readLong();
		mDisplayName = in.readString();
		mDisplayNumber = in.readString();
		mIsUse = false;
	}

	public static final Parcelable.Creator<ContactsWrapper> CREATOR = new Parcelable.Creator<ContactsWrapper>() {
		public ContactsWrapper createFromParcel(Parcel in) {
			return new ContactsWrapper(in);
		}

		public ContactsWrapper[] newArray(int size) {
			return new ContactsWrapper[size];
		}
	};

	@Override
	public int describeContents() {
		return hashCode();
	}

	/**
	 * Ghi nội dung object vào parcel
	 */
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(mContactId);
		dest.writeString(mDisplayName);
		dest.writeString(mDisplayNumber);
	}

	public boolean isIsUse() {
		return mIsUse;
	}

	public void setIsUse(boolean mIsUse) {
		this.mIsUse = mIsUse;
	}

}
